//
//  DKBaseViewController.m
//  DanKU
//
//  Created by 吴斌 on 2023/9/26.
//

#import "DKBaseViewController.h"
#import "DKAuthFeedBackAlertView.h"
@interface DKBaseViewController ()

@end

@implementation DKBaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBar.hidden = YES;
    self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    
}
-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    [self makeDragBtn];
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [_dk_DragBtn removeFromSuperview];
    _dk_DragBtn = nil;
}
-(DKDragButton *)dk_DragBtn{
    if(!_dk_DragBtn){
        _dk_DragBtn = [[DKDragButton alloc] init];
        _dk_DragBtn.rootView = self.view.superview;
        [UIApplication.sharedApplication.delegate.window addSubview:self.dk_DragBtn];
        [_dk_DragBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@(-DK_IsWidthScale(0)));
            make.top.equalTo(@(DK_IsWidthScale(15)+DK_SafeAreaTop));
            make.width.equalTo(@(DK_IsWidthScale(55)));
            make.height.equalTo(@(DK_IsWidthScale(40)));
        }];
        self.dk_DragBtn.tapDragBlock = ^{//悬浮反馈
            [DKAuthFeedBackAlertView dk_ShowAuthFeedBackAlertView:^{
                
            }];
        };
    }
    return _dk_DragBtn;
}
- (void)makeDragBtn{
    DKRegisterUserModel * dkRegisterUserMdl = [DKGlobalHelper getRegisterUserInfo];
    if(dkRegisterUserMdl&&dkRegisterUserMdl.token.length){
        [self dk_DragBtn];
    }
}
- (void)makeNavBack{
    //返回
    UIButton * dk_forgetPwdBackBtn = [[UIButton alloc] init];
    [dk_forgetPwdBackBtn setBackgroundImage:DK_GetImage(@"dk_registerBack") forState:UIControlStateNormal];
    [dk_forgetPwdBackBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:dk_forgetPwdBackBtn];
    [dk_forgetPwdBackBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.top.equalTo(@(DK_IsWidthScale(12)+DK_SafeAreaTop));
        make.width.equalTo(@(DK_IsWidthScale(20)));
        make.height.equalTo(@(DK_IsWidthScale(20)));
    }];
}
- (void)makeShowNavBack{
    UIButton *rightButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
    [rightButton addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    [rightButton setImage:DK_GetImage(@"dk_registerBack") forState:UIControlStateNormal];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
    self.navigationItem.leftBarButtonItems = @[rightItem];

}
- (void)goBack{
    [self.navigationController popViewControllerAnimated:YES];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
